package br.com.chat.server;

import java.io.InputStream;
import java.util.Scanner;

public class ClientBridge implements Runnable {
	  private InputStream client;
	   private Server server;
	 
	   public ClientBridge(InputStream client, Server server) {
	     this.client = client;
	     this.server = server;
	   }
	 
	   public void run() {
	     // quando chegar uma msg, distribui pra todos
	     Scanner s = new Scanner(this.client);
	     while (s.hasNextLine()) {
	       server.distribuiMensagem(s.nextLine());
	     }
	     s.close();
	   }
}
